# Contributor: Aurelien Foret <orelien@chez.com>
# Maintainer (Arch): Douglas Soares de Andrade <douglas@archlinux.org>
# Maintainer : Sagar Acharya <sagar@hyperbola.info>

pkgname=patchutils
pkgver=0.4.2
pkgrel=1
pkgdesc="A small collection of programs that operate on patch files"
license=('GPL-2')
url="http://cyberelk.net/tim/patchutils/"
depends=('python' 'pcre2')
makedepends=('xmlto' 'quilt')
arch=('any')
source=("http://cyberelk.net/tim/data/patchutils/stable/$pkgname-$pkgver.tar.xz"{,.sig}
		"series"
		"espdiff_man_6.patch"
		"posixness_fix.patch")
sha512sums=('20970d52fd43c09dc7799297b9a9eb6f60ba29ecc750d49381a2dc52273dfe484a47696cddd541f623394fa3486734cf337297cbeab6b1b244511c7740f46897'
            'SKIP'
            'dca7ea0002dc02ca08334ac4f1b77e895ad81aaf8d53acd85d097040b3309f5ff4a7b390049cc1f37c1c50ac97dd2db3aa83106bc3973b2180120d08d04e0401'
            '81b1ada959bbab496e539358a0e28bf2ffff13fa183161da2b0df87d955c5f8e5d08dd3a0cb399235efc121520d102f53ec0842c3bff0f12c824002a3a3e6745'
            '5d768c17a28fe02a3e4dfb43f691f7bbbe2b3e48412d170673944bedf384a1dce367007b419b77ea725424b11f52eb0f8bda4853de2aea01c1cb94d9563ac9a4')
validpgpkeys=('4629AFE960EC20BEC12E3104B7C20D079491EA63') # Tim Waugh <tim@cyberelk.net>

# Manually import above key with command below
# wget -qO - http://cyberelk.net/tim/twaugh.asc | gpg --import

prepare() {
  cd "${srcdir}"/"${pkgname}-${pkgver}"

  mkdir ./patches
  cp ${srcdir}/series ./patches
  cp ${srcdir}/*.patch ./patches

  export QUILT_PATCHES=patches
  export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
  export QUILT_DIFF_ARGS='--no-timestamps'

  quilt push -av
}

build() {
  cd "${srcdir}"/${pkgname}-${pkgver}

  ./configure --prefix=/usr
  make
}

package() {
  cd "${srcdir}"/${pkgname}-${pkgver}

  make DESTDIR="${pkgdir}" install
}
